package com.talking.presenter;

import com.talking.model.Http;

import org.json.JSONException;
import org.json.JSONObject;

import okhttp3.Callback;

public class FriendPresenter {
    public static void addFriend(String account,String friendAccount,String remarkMe,String remarkFriend,Callback callback){
        try {
            JSONObject jo=new JSONObject();
            jo.put("account",account);
            jo.put("friendAccount",friendAccount);
            jo.put("remarkFriend",remarkFriend);
            jo.put("remarkMe",remarkMe);
            Http.post(jo,"friend/createFriend/",callback);
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
    public static void query(String account,Callback callback) {
        Http.get("friend/query/?account="+account,callback);
    }
    public static void querySingle(String account,String friendAccount,Callback callback) {
        Http.get("friend/querySingle/?account="+account+"&friendAccount="+friendAccount,callback);
    }
    public static void modifyRemark(String account,String friendAccount,String remark,Callback callback){
        try {
            JSONObject jo=new JSONObject();
            jo.put("account",account);
            jo.put("friendAccount",friendAccount);
            jo.put("remark",remark);
            Http.post(jo,"friend/modifyRemark/",callback);
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
    public static void delete(String account,String friendAccount,Callback callback){
        try {
            JSONObject jo=new JSONObject();
            jo.put("account",account);
            jo.put("friendAccount",friendAccount);
            Http.post(jo,"friend/dropFriends/",callback);
        } catch (JSONException e) {
            e.printStackTrace();
        }
    };

    public static void getFriendsWhoNotInGroup(String account,String groupId,Callback callback) {
        Http.get("friend/getFriendsWhoNotInGroup/?account="+account+"&groupId="+groupId,callback);
    }
}